/**
 * @desc
 *
 * @使用场景
 *
 * @author  杨晓东[of1081]
 * @company qianmi.com
 * @Date    15/10/21
 **/
'use strict';
let commonUtil = require('@qianmi/x-site-common/util/common-util').default;
let {join} = require('path');
let {readJsonSync} = require('fs-extra');
/**
 * 如果在环境变量中配置了,配置文件目录, 则从配置文件目录中取数据. .
 */
//通过文件来读取.
let config;
if(process.env.XSITE_TPL_CONFIG_DIR){
    config ={
        envCode:commonUtil.getEnvCode(),
        configJS:readJsonSync(join(process.env.XSITE_TPL_CONFIG_DIR,'config.json')),
        ossConfig:readJsonSync(join(process.env.XSITE_TPL_CONFIG_DIR,'oss-config.json')),
        memcacheConfig:readJsonSync(join(process.env.XSITE_TPL_CONFIG_DIR,'memcache-config.json')),
        dataBaseConfig:readJsonSync(join(process.env.XSITE_TPL_CONFIG_DIR,'data-base-config.json')),
        allDBInfoConfig:readJsonSync(join(process.env.XSITE_TPL_CONFIG_DIR,'mongodb-info-config.json'))
    };
}else{
    config ={
        envCode:commonUtil.getEnvCode(),
        configJS:require('./dev/config'),
        ossConfig:require('./dev/oss-config'),
        memcacheConfig:require('./dev/memcache-config'),
        dataBaseConfig:require('./dev/data-base-config'),
        allDBInfoConfig:require('./dev/mongodb-info-config')
    }
}

console.log('配置信息为: ',config);
module.exports = config;


